﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;

namespace Web.admin.InnerManage
{
    public partial class ListInnerProc : System.Web.UI.Page
    {
        private ContestService contestService = new ContestService();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id = Request["id"];
                if (String.IsNullOrEmpty(id))
                    return;

                btn_Add.NavigateUrl = "AddInnerProc.aspx?ContestId=" + id;

                BoContests contest = new BoContests();
                contest.CON_ID = id;
                RpList.DataSource = contestService.GetContestProcedures(contest);
                RpList.DataBind();
            }
        }

        protected void btn_Delete_Click(object sender, EventArgs e)
        {
            int j = 0;
            for (int i = 0; i < RpList.Items.Count; i++)
            {
                string id = ((HiddenField)RpList.Items[i].FindControl("Hf_id")).Value;
                CheckBox cb = (CheckBox)RpList.Items[i].FindControl("CbChoose");
                BoContests ccc = contestService.getContest(id);
                if (cb.Checked)
                {
                    contestService.DeleteContest(ccc);
                    j++;
                }
            }
            Response.Write("<script>alert('删除成功，共删除" + j + "条数据');window.location.href='ListInnerProc.aspx'; </script>");
            return;
        }
        }
    
}